﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using LeHouse.Server.Dto;
using LeHouse.Server.Service;

namespace LeHouse.Server.WebApi.Controllers
{
    public class InquiryRecordController : ApiController
    {
        Collateral_InquiryRecordService service = new Collateral_InquiryRecordService();

        [HttpGet]
        [Route("api/InquiryRecord/GetInquiryRecord")]
        public dynamic GetInquiryRecord([FromUri] string P_ReportNumber)
        {
            Collateral_InquiryRecord tp = new Collateral_InquiryRecord();
            List<Collateral_InquiryRecord> ltp = service.Community(P_ReportNumber, out tp);
            return new
            {
                ltp = ltp,
                tp = tp
            };
        }

        /// <summary>
        /// 显示询价记录表信息
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("api/InquiryRecord/Selectbyid")]
        public List<Collateral_InquiryRecord> Selectbyid([FromUri] string P_ReportNumber)
        {
            if (service.count(P_ReportNumber) <= 0)
            {
                return null;
            }
            else
            {
                List<Collateral_InquiryRecord> select = service.Community(P_ReportNumber);
                return select;
            }
        }
        [HttpPost]
        [Route("api/InquiryRecord/InsertInquiryRecord")]
        public bool InsertInquiryRecord([FromBody] Collateral_InquiryRecord o)
        {
            return service.InsertInquiryRecord(o);
        }
    }
}
